package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ExtractingMatchedExpressionsEmailAddressFinder {
	public static void main(String[] argv) {
		Pattern pattern = Pattern.compile(
				"([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]"
						+ "{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))"
						+ "([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)", Pattern.MULTILINE);

		Matcher matcher = pattern.matcher("");
		boolean matched = false;
		matcher.reset("asdfs@tah1986.com");
		while (matcher.find()) {
			System.out.println("\t" + matcher.group());

			matched = true;
		}
		if (!matched) {
			System.out.println("\t没有电子邮件地址");
		}
	}
}
